﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MyDemos.UIComponent
{
    public partial class Component : UserControl
    {
        public Component ()
        {
            InitializeComponent ();

            LayoutRoot.DataContext = this;

            MyHeight = 0;
            MyWidth = 200;
        }

        public int MyWidth
        {
            get;
            set;
        }

        public int MyHeight
        {
            get
            {
                return (int)GetValue (MyHeightProperty);
            }
            set
            {
                SetValue (MyHeightProperty, value);
            }
        }

        private static String mOldValue ;
        private static String mNewValue ; 

        public String OldValue
        {
            get
            {
                return mOldValue;
            }
            set
            {
                mOldValue = value;
            }
        }

        public String NewValue
        {
            get
            {
                return mNewValue;
            }
            set
            {
                mNewValue = value;
            }
        }


        public static readonly DependencyProperty MyHeightProperty =
            DependencyProperty.Register ("MyHeight", typeof (int), typeof (Component),new PropertyMetadata(100,OnPrivateDataContextChanged));

        private static void OnPrivateDataContextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            mOldValue = e.OldValue.ToString ();
            mNewValue = e.NewValue.ToString ();

        }
    }
}
